<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>等待支付</title>
	<meta name="author" content="XUE">
	<meta name="description" content="普济一城">
	<meta name="viewport" content="initial-scale=1,maximum-scale=1">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="transparent">
	<meta name="format-detection" content="telephone=no,email=no">
	<link rel="stylesheet" type="text/css" href="../../css/base.css">
	<link rel="stylesheet" type="text/css" href="../../css/product-order/payment.css">
	<link rel="stylesheet" type="text/css" href="../../css/layer.css">
</head>
<body>
	<!-- head -->
	<div class="head">
		<p>支付订单</p>
		<div class="head-img">
			<img src="../../img/d_share.png">
		</div>
	</div>
	<!-- main -->
	<div class="main">
		<div class="main-a">
			<div class="main-pic">
				<img src="../../img/d_chenggong.png">
			</div>
			<p>订单提交成功</p>
		</div>
		<div class="main-b">
			<p class="timer" id="shijian">请在00小时29分59秒内完成支付</p>
			<p class="zfje">支付金额：<span class="maney">¥<span class="maney-a">0.00</span></span></p>
		</div>
	</div>
	<!--  method -->
	<div class="method">
		<p class="fkfs">付款方式</p>
		<div class="method-a">
			<div class="methoda-left">
				<div class="method-pic">
					<img src="../../img/d_weixinzhifu.png">
				</div>
				<p class="wxzf">微信支付</a></p>
			</div>
			<div class="methoda-right">
				<img src="../../img/d_cart3.png">
			</div>
		</div>
		<div class="method-b">
			<div class="methodb-left">
				<div class="method-pic">
					<img src="../../img/d_zhifubao.png">
				</div>
				<p class="zfbzf">支付宝支付</p>
			</div>
			<div class="methodb-right">
				<img src="../../img/d_cart3.png">
			</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="../../js/zepto.min.js"></script>
<script type="text/javascript" src="../../js/layer.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript">
	//返回
$('.head-img').on('click',function(){
	if(globalFun.GetQueryString('from')=="app"){
		 houtui()
	}else{
		window.history.go(-1);
	}
})
function houtui() {
	var ua = navigator.userAgent.toLowerCase();
	if(/pjyc_i/.test(ua)) {
		setupWebViewJavascriptBridge(function(bridge) {
			bridge.callHandler('goBack',function(resp) {});
		});
	} else if(/pujiyicheng/.test(ua)) {
		//var result = lase;
		window.stub.goBack(); //用接口stub, 通过调用内部类中的方法jsMethod给java传回result。

	}
}
	Auth();

	var maney;
	var spId = localStorage.getItem("spId");
    var orderIds = globalFun.GetQueryString('orderIds');
    var oId = globalFun.GetQueryString('oid');
	maney = localStorage.getItem("orderTotalPrice");
	console.log(maney)
	$('.maney-a').html(maney)
//	// 微信支付
	$('.method-a').on('click',function(){
		if(mark==2){
		var dataObj = {
			phone: user_info.phone,
			//phone: '18510617776',
			uuid: user_info.uuid,
			//uuid: "7709a0c3fed64fc1b8ec6ddb24226448",
			// orderIds:'773,774',
			orderIds:orderIds,
			type:0
		}
		$.ajax({
			type:"post",
			url:apicom +"mobile/after/payOrder/sendUnifiedOrder",
			// '&redirect_url=http%3a%2f%2fpjyc.sht315.com%2fhtml%2fhomePage%2fsy.html
			//url:"http://pjyc.sht315.com:10001/mobile/after/payOrder/sendUnifiedOrder",
			data:dataObj,
			async: false,
			dataType: "json",
			success:function(res){
				console.log(res);

				if(typeof(res) == 'string'){
					res = JSON.parse(res);
				}
				if(res.code == 1){
					var url = res.content.url;
					var dz = url+'&redirect_url=http%3a%2f%2fpjyc.sht315.com%2fhtml%2fhomePage%2fsy.html'
					//var dz = url
					console.log(dz)
					window.location.href = dz

				} else{
					tips(res.msg)
				}
			},
			error:function(err){
				console.log(err)
			}
		})
		}else{
		var dataObj = {
				orderNums:orderIds,
				orderMoney:maney,
				orderId:oId,
				type:0
			}
			var dataObjT = JSON.stringify(dataObj);
			weixin(dataObjT);
		}
	})
	// 支付宝
	$('.method-b').on('click',function(){
		if(mark==2){
		var data = {
			phone: user_info.phone,
			//phone: '18510617776',
			uuid: user_info.uuid,
			//uuid: "7709a0c3fed64fc1b8ec6ddb24226448",
			orderIds:orderIds,
			// orderIds:'773,774',
			type:1
		};
		$.post(apicom +"mobile/after/payOrder/sendUnifiedOrder",data,function(res){
			if(typeof(res) == 'string'){
				res = JSON.parse(res);
			}
			var vv = JSON.parse(res.content)
			console.log(vv)

			window.location.href = 'https://openapi.alipay.com/gateway.do?'+vv.body
		})
		}else{
			var dataObj = {
				orderNums:orderIds,
				orderMoney:maney,
				orderId:oId,
				type:0
			}
			var dataObjT = JSON.stringify(dataObj);
			zhifubao(dataObjT);
		}
	})
	// 返回
//	$('.head-img').on('click',function(){
//		localStorage.setItem('orderStatus',8);
//		window.location.href = rootdomain +'html/order/my_order.html?from=zxx'
//	})
	// 微信
	function weixin(dataObj){
    	var ua = navigator.userAgent.toLowerCase();
        if (/pjyc_i/.test(ua)) {
            setupWebViewJavascriptBridge(function(bridge){
                bridge.callHandler('jsWeChatpayment',dataObj,function(resp){});
              });
            } else if (/pujiyicheng/.test(ua)) {

                //var result = lase;
               window.stub.jsToWeChatpay(dataObj);//用接口stub, 通过调用内部类中的方法jsMethod给javas传回result。

         }
	}

	// 支付宝
	function zhifubao(dataObj){

    	var ua = navigator.userAgent.toLowerCase();
        if (/pjyc_i/.test(ua)) {
            setupWebViewJavascriptBridge(function(bridge){
                bridge.callHandler('jsAlipaypayment',dataObj,function(resp){});
              });
            } else if (/pujiyicheng/.test(ua)) {
                //var result = lase;
               window.stub.jsToAlipay(dataObj);//用接口stub, 通过调用内部类中的方法jsMethod给javas传回result。

         }
	}

	//ios支付成功失败
	 if (mark==1) {
         setupWebViewJavascriptBridge(function(bridge){
           bridge.registerHandler('StatePayment',function(data,resp){
           		if(data == 0){
           			tips('支付失败')
           		} else if(data == 1){
           			window.location.href = rootdomain +'html/product-order/paysuccess.html?status=1&money='+maney;
           		} else if(data == 2){
           			tips('支付失败')
           		} else if(data == 3){
           			window.location.href = rootdomain +'html/product-order/paysuccess.html?status=3&money='+maney;
           		}
           })
         })
       }
       if(mark==0) {
       		function paySuccess(data){
       			if(data == 1){
           			window.location.href = rootdomain +'html/product-order/paysuccess.html?status=1&money='+maney;
           		} else if(data == 3){
           			window.location.href = rootdomain +'html/product-order/paysuccess.html?status=3&money='+maney;
           		}
       		}
       }
//倒计时
	var creattime = localStorage.getItem("createdTime")/1
	console.log(creattime)
	var shixiaotime = creattime + (30 * 60 * 1000)
//				new Date($.ajax({async: false}).getResponseHeader("Date"));
	var date = new Date($.ajax({async: false}).getResponseHeader("Date"));
	var timer1 = date.getTime()
	var time2 = shixiaotime - timer1
	addTimer("shijian",time2)

//倒计时
//window.onload = function(){
		function addTimer(id,time){
			var list = [],
				interval;
			document.getElementById(id).innerHTML = getTimerString(time);
			if(time<0){
				return
			}
			interval = setInterval(function(){
				time-=1000
				document.getElementById(id).innerHTML = getTimerString(time);
			}, 1000);
			function getTimerString(time) {
				var m = Math.floor((time / 1000) / 60),
					s = Math.floor((time % 60000)/1000);
					if(time>0){
						if(m<0) m= 0;
						return "剩" + m + "分钟" + s + "秒自动关闭";
					}else{
						$("#order_fukuan").off('click')
						interval = null;
						return "时间到,订单已关闭";
					}
				}
		}
//		}

</script>
</html>
